package eu.scillman.net.tcp;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;

import eu.scillman.interfaces.ICommConstants;

public class ClientSun {
	/**
	 * The original sample from Sun!
	 * @param args
	 */
	public static void main(String args[]) {
		try {
			Socket skt = new Socket("localhost", 54016);
			skt.setSoTimeout(ICommConstants.CONNECTION_TIMEOUT);
			
			BufferedReader in = new BufferedReader(new
					InputStreamReader(skt.getInputStream()));
			System.out.print("Received string: '");
			
			

			while (!in.ready()) {
				Thread.yield();
			}
			System.out.println(in.readLine()); // Read one line and output it

			System.out.print("'\n");
			in.close();
			skt.close();
		}
		catch (Exception ex) {
			System.out.println("Whoops! It didn't work!");
			System.out.println(ex.toString() + ": " + ex.getMessage());
		}
	}
}
